package A13;


import java.util.List;

public class Student {
    private String studentId; // 学号（如"2024001001"）
    private String studentName; // 学生姓名
    private List<Subject> selectedSubjects; // 关联：1~5门课程

    public Student(String studentId, String studentName) {
        this.studentId = studentId;
        this.studentName = studentName;
    }

    // 选修课程（限制最多5门）
    public void selectSubject(Subject subject) {
        if (selectedSubjects == null) {
            throw new IllegalStateException("请先初始化selectedSubjects集合！");
        }
        if (selectedSubjects.size() >= 5) {
            throw new IllegalStateException("约束：学生最多选修5门课程！");
        }
        selectedSubjects.add(subject);
    }

    // getter/setter
    public String getStudentId() {
        return studentId;
    }

    public String getStudentName() {
        return studentName;
    }

    public List<Subject> getSelectedSubjects() {
        return selectedSubjects;
    }

    public void setSelectedSubjects(List<Subject> selectedSubjects) {
        this.selectedSubjects = selectedSubjects;
    }
}